/* GUI CONVERTED from mrmprp1g.p (converter v1.75) Sun Aug 13 17:21:52 2000 */
/* mrmprp1g.p - MRP DETAIL REPORT BOM/FORMULA CODE SORT                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* web convert mrmprp1g.p (converter v1.00) Fri Oct 10 13:58:13 1997 */
/* web tag in mrmprp1g.p (converter v1.00) Mon Oct 06 14:18:56 1997 */
/*F0PN*/ /*K103*/ /*                                                    */
/*V8:ConvertMode=Report                                        */
/* REVISION: 7.5    LAST MODIFIED: 03/03/95     BY: tjs *J014*          */
/* REVISION: 8.6    LAST MODIFIED: 10/15/97     BY: ckm *K103*          */
/* REVISION: 8.6    LAST MODIFIED: 04/13/98     BY: *J2JD* Sachin Shah  */
/* REVISION: 8.6E   LAST MODIFIED: 10/13/98     BY: *L0BY* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00 BY: *N0KR* myb              */
/*J2JD* GROUPED MULTIPLE FIELD ASSIGNMENTS INTO ONE AND ADDED NO-UNDO
        WHEREVER MISSING FOR PERFORMANCE AND SMALLER R-CODE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT
     {mfdeclre.i}

{gplabel.i} /* EXTERNAL LABEL INCLUDE */
/*K103*/ {wbrp02.i}

     define new shared variable fcsduedate  as date.
     define new shared variable fcssite     like si_site.
     define new shared variable fcspart     like pt_part.

     define shared variable part         like pt_part NO-UNDO.
     define shared variable part1        like pt_part NO-UNDO.
     define shared variable bom          like wo_bom_code NO-UNDO.
     define shared variable bom1         like wo_bom_code NO-UNDO.
     define shared variable site         like si_site NO-UNDO.
     define shared variable site1        like si_site NO-UNDO.
     define shared variable buyer        like pt_buyer NO-UNDO.
     define shared variable prod_line    like pt_prod_line NO-UNDO.
     define shared variable ptgroup      like pt_group NO-UNDO.
     define shared variable part_type    like pt_part_type NO-UNDO.
     define shared variable vendor       like pt_vend NO-UNDO.
     define shared variable pm_code      like pt_pm_code NO-UNDO.
     define shared variable show_base    like mfc_logical NO-UNDO.
     define shared variable frwrd        like soc_fcst_fwd.
     define shared variable bck          like soc_fcst_bck.

     define variable gross               as decimal
        format "->>>,>>>,>>9.9<<<<<<<<" NO-UNDO.
     define variable recpt               like gross NO-UNDO.
     define variable ord                 like gross NO-UNDO.
     define variable qoh                 like gross NO-UNDO.
     define variable due_date            like mrp_due_date NO-UNDO.
     define variable i                   as integer NO-UNDO.
     define variable j                   as integer NO-UNDO.
     define variable week                as integer NO-UNDO.
     define variable lead                as integer NO-UNDO.
     define variable detail              as character format "x(70)" NO-UNDO.
     define variable desc1               as character format "x(50)" NO-UNDO.
     define variable mrp_reqd            like pt_mrp NO-UNDO.
     define variable qty_oh              like in_qty_oh NO-UNDO.
     define variable get_1st_item        like mfc_logical NO-UNDO.

     define temp-table t_table no-undo
           field t_key     as character
           field t_file    as character
           field t_part    like pt_part
           field t_bom     like pt_bom_code
/*J2JD*/   field t_site    like si_site
     index t_index is primary t_key ascending.

/*J2JD**     for each si_mstr no-lock **/
/*J2JD**     where si_site >= site and si_site <= site1: **/

        /* BUILD WORKFILE OF ITEM MASTER DATA */
/*J2JD*/ for each in_mstr fields(in_mrp in_part in_qty_oh in_site) no-lock
/*J2JD*/    where in_site >= site and in_site <= site1
/*J2JD*/      and in_part >= part and in_part <= part1
/*J2JD*/ break by in_site by in_part:

/*J2JD** for each pt_mstr no-lock where **/
/*J2JD** pt_part >= part and pt_part <= part1: **/

/*J2JD* BEGIN ADD */
            for first pt_mstr
            fields(pt_bom_code pt_buyer pt_cum_lead pt_desc1 pt_desc2 pt_group
                   pt_insp_lead pt_insp_rqd pt_iss_pol pt_joint_type pt_mfg_lead
                   pt_mrp pt_ms pt_ord_max pt_ord_min pt_ord_mult pt_ord_per pt_ord_pol
                   pt_ord_qty pt_part pt_part_type pt_plan_ord pt_pm_code pt_prod_line
                   pt_pur_lead pt_sfty_stk pt_sfty_time pt_timefence pt_um pt_vend pt_yield_pct)
            no-lock where
        pt_part = in_part:
            end.
/*J2JD* END ADD */

           if (pt_prod_line = prod_line or prod_line = "") and
          (pt_group     = ptgroup   or ptgroup   = "") and
          (pt_part_type = part_type or part_type = "")
           then do:

/*J2JD**  find first ptp_det no-lock where **/
/*J2JD**  ptp_part = pt_part and ptp_site = si_site no-error. **/

/*J2JD* BEGIN ADD */
               for first ptp_det
               fields(ptp_bom_code ptp_buyer ptp_cum_lead ptp_ins_Lead
                      ptp_ins_rqd ptp_iss_pol ptp_joint_type  ptp_mfg_lead
                      ptp_ms ptp_ord_max ptp_ord_min ptp_ord_mult ptp_ord_per
                      ptp_ord_pol ptp_ord_qty ptp_part ptp_plan_ord ptp_pm_code
                      ptp_pur_lead ptp_sfty_stk ptp_sfty_tme ptp_site
                      ptp_timefnce ptp_vend ptp_yld_pct)
               no-lock where ptp_part = pt_part and ptp_site = in_site: end.
/*J2JD* END ADD */

          if (available ptp_det and
              (ptp_buyer   = buyer   or buyer = "") and
              (ptp_vend    = vendor  or vendor = "") and
              (ptp_pm_code = pm_code or pm_code = "") and
              (show_base or (not show_base and ptp_joint_type <> "5"))
              and
              ((ptp_bom_code <> "" and
            ptp_bom_code >= bom and ptp_bom_code <= bom1) or
               (ptp_bom_code =  "" and
            ptp_part     >= bom and ptp_part     <= bom1)))
          or (not available ptp_det and
              (pt_buyer    = buyer   or buyer = "") and
              (pt_vend     = vendor  or vendor = "") and
              (pt_pm_code  = pm_code or pm_code = "") and
              (show_base or (not show_base and pt_joint_type <> "5"))
              and
              ((pt_bom_code <> "" and
            pt_bom_code >= bom and pt_bom_code <= bom1) or
               (pt_bom_code =  "" and
            pt_part     >= bom and pt_part     <= bom1)))
          then do:

             create t_table.

             if available ptp_det then do:
            assign
               t_file = "ptp_det"
               t_part = ptp_part
               t_bom  = ptp_bom_code
/*J2JD*/       t_site = in_site.
            if ptp_bom_code <> "" then
               assign t_key =
               string(ptp_bom_code,"x(18)") + string(ptp_part).
            else
               assign t_key = string(ptp_part,"x(18)") + string(ptp_part).
             end.
             else do:
            assign
               t_file = "pt_mstr"
               t_part = pt_part
               t_bom  = pt_bom_code
/*J2JD*/       t_site = in_site.
            if pt_bom_code <> "" then
               assign t_key =
               string(pt_bom_code,"x(18)") + string(pt_part).
            else
               assign t_key = string(pt_part,"x(18)") + string(pt_part).
             end.
          end. /* if (available ptp_det */
           end. /* if (pt_prod_line */
/*J2JD**  end. /* for each pt_mstr */ **/
/*J2JD*/ end. /* for each in_mstr */

        for each t_table:

/*J2JD*/       for first si_mstr fields (si_site)
/*J2JD*/       where si_site = t_site no-lock: end.
/*J2JD*/       for first in_mstr fields(in_mrp in_part in_qty_oh in_site) no-lock
/*J2JD*/       where in_site = t_site and in_part = t_part: end.

           if t_file = "ptp_det" then do:
/*J2JD**  find ptp_det no-lock where **/
/*J2JD**  ptp_part = t_part and ptp_site = si_site no-error. **/

/*J2JD* BEGIN ADD */
                  for first ptp_det
                  fields(ptp_bom_code ptp_buyer ptp_cum_lead ptp_ins_Lead
                         ptp_ins_rqd ptp_iss_pol ptp_joint_type  ptp_mfg_lead
                         ptp_ms ptp_ord_max ptp_ord_min ptp_ord_mult ptp_ord_per
                         ptp_ord_pol ptp_ord_qty ptp_part ptp_plan_ord ptp_pm_code
                         ptp_pur_lead ptp_sfty_stk ptp_sfty_tme ptp_site
                         ptp_timefnce ptp_vend ptp_yld_pct)
                  no-lock where ptp_part = t_part and ptp_site = t_site: end.
/*J2JD* END ADD */
           end.

/*J2JD**   find pt_mstr no-lock where pt_part = t_part no-error. **/

/*J2JD* BEGIN ADD */
            for first pt_mstr
            fields(pt_bom_code pt_buyer pt_cum_lead pt_desc1 pt_desc2 pt_group
                   pt_insp_lead pt_insp_rqd pt_iss_pol pt_joint_type pt_mfg_lead
                   pt_mrp pt_ms pt_ord_max pt_ord_min pt_ord_mult pt_ord_per pt_ord_pol
                   pt_ord_qty pt_part pt_part_type pt_plan_ord pt_pm_code pt_prod_line
                   pt_pur_lead pt_sfty_stk pt_sfty_time pt_timefence pt_um pt_vend pt_yield_pct)
             no-lock where pt_part = t_part: end.
/*J2JD* END ADD */

           /* FIND in_mstr, mrp_det, fsworkfile AND DISPLAY */
           {mrmprp1h.i}

           
/*GUI*/ {mfguichk.i  &warn=no} /*Replace mfrpchk*/


        end. /* for each t_table */

/*J2JD**        {mfrpchk.i &warn=yes} **/

/*J2JD**     end. /* for each si_mstr */ **/
/*K103*/ {wbrp04.i}
